package com.fc.test.controller.gen;

import com.alibaba.fastjson.JSONObject;
import com.fc.test.model.auto.EntCollect;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageInfo;
import com.fc.test.common.base.BaseController;
import com.fc.test.common.domain.AjaxResult;
import com.fc.test.model.auto.JobRec;
import com.fc.test.model.custom.TableSplitResult;
import com.fc.test.model.custom.Tablepar;
import com.fc.test.model.custom.TitleVo;
import com.fc.test.service.JobRecService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(value = "职位推荐信息")
@Controller
@RequestMapping("/JobRecController")
public class JobRecController extends BaseController{
	
	private String prefix = "gen/jobRec";
	@Autowired
	private JobRecService jobRecService;
	
	/**
	 * 分页跳转
	 */
	@ApiOperation(value = "分页跳转", notes = "分页跳转")
	@GetMapping("/view")
//	@RequiresPermissions("gen:jobRec:view")
    public String view(ModelMap model)
    {	
		String str="职位推荐信息";
		setTitle(model, new TitleVo("列表", str+"管理", true,"欢迎进入"+str+"页面", true, false));
        return prefix + "/listForSys";
    }
	
	/**
	 * 分页查询
	 */
	//@Log(title = "职位推荐信息集合查询", action = "111")
	@ApiOperation(value = "分页查询", notes = "分页查询")
	@PostMapping("/list")
//	@RequiresPermissions("gen:jobRec:list")
	@ResponseBody
	public Object list(@RequestBody JobRec jobRec){
		Tablepar tablepar = new Tablepar();
		PageInfo<JobRec> page=jobRecService.list(tablepar,jobRec) ;
		TableSplitResult<JobRec> result=new TableSplitResult<JobRec>(page.getPageNum(), page.getTotal(), page.getList()); 
		return  result;
	}

	/**
	 * 分页查询
	 */
	//@Log(title = "企业收藏集合查询", action = "111")
	@ApiOperation(value = "企业收藏集合查询", notes = "企业收藏集合查询")
	@PostMapping("/listForSys")
//	@RequiresPermissions("gen:noticeInfo:list")
	@ResponseBody
	public Object listForSys(Tablepar tablepar, JobRec jobRec){
		PageInfo<JobRec> page=jobRecService.listForSys(tablepar,jobRec) ;
		TableSplitResult<JobRec> result=new TableSplitResult<JobRec>(page.getPageNum(), page.getTotal(), page.getList());
		return  result;
	}
	
	/**
     * 新增跳转
     */
    @ApiOperation(value = "新增跳转", notes = "新增跳转")
    @GetMapping("/add")
    public String add(ModelMap modelMap)
    {
        return prefix + "/add";
    }
	
	/**
     * 新增
     */
	//@Log(title = "职位推荐信息新增", action = "111")
   	@ApiOperation(value = "新增", notes = "新增")
	@PostMapping("/add")
//	@RequiresPermissions("gen:jobRec:add")
	@ResponseBody
	public AjaxResult add(@RequestBody JobRec jobRec){
		int b=jobRecService.insertSelective(jobRec);
		if(b>0){
			return success();
		}else{
			return error();
		}
	}
	
	/**
	 * 删除
	 * @param ids
	 * @return
	 */
	//@Log(title = "职位推荐信息删除", action = "111")
	@ApiOperation(value = "删除", notes = "删除")
	@PostMapping("/remove")
//	@RequiresPermissions("gen:jobRec:remove")
	@ResponseBody
	public AjaxResult remove(String ids){
		int b=jobRecService.deleteByPrimaryKey(ids);
		if(b>0){
			return success();
		}else{
			return error();
		}
	}
	
	/**
	 * 检查Name
	 * @param tsysUser
	 * @return
	 */
	@ApiOperation(value = "检查Name唯一", notes = "检查Name唯一")
	@PostMapping("/checkNameUnique")
	@ResponseBody
	public int checkNameUnique(JobRec jobRec){
		int b=jobRecService.checkNameUnique(jobRec);
		if(b>0){
			return 1;
		}else{
			return 0;
		}
	}
	
	
	/**
	 * 修改跳转
	 * @param id
	 * @param mmap
	 * @return
	 */
	@ApiOperation(value = "修改跳转", notes = "修改跳转")
	@GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        mmap.put("JobRec", jobRecService.selectByPrimaryKey(id));

        return prefix + "/edit";
    }
	
	/**
     * 修改保存
     */
    //@Log(title = "职位推荐信息修改", action = "111")
    @ApiOperation(value = "修改保存", notes = "修改保存")
//    @RequiresPermissions("gen:jobRec:edit")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody JobRec jobRec)
    {
		return toAjax(jobRecService.updateByPrimaryKeySelective(jobRec));
    }

    
    /**
   	 * 根据主键查询
   	 * 
   	 * @param id
   	 * @param mmap
   	 * @return
   	 */
   	@ApiOperation(value = "根据id查询唯一", notes = "根据id查询唯一")
	@RequestMapping("/get/{id}")
	@ResponseBody
   	public JobRec edit(@PathVariable("id") String id) {
   		return jobRecService.selectByPrimaryKey(id);
   	}
    

	
}
